<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px;
            background-color: rgb(27, 27, 230);
            color: white;
        }

        .container {
            display: flex;
        }

        .container aside {
            width: 100px;
            background-color: aqua;
            color: #eee;
            text-align: center;
            line-height: 40px;

        }

        .container aside div.active {
            background-color: #555;
            color: white;
        }

        .container main {
            flex: 1;
            padding: 20px;
        }

        .container main .inputbox {
            margin: 20px 0;
        }

        .container main .inputbox input {
            height: 40px;
            border-radius: 20px;
            width: 300px;
            padding-left: 20px;
            outline: none;
            border: 1px solid #ccc;
        }

        .container main .inputbox button {
            background-color: seagreen;
            border-radius: 5px;
            text-align: center;
            line-height: 40px;
            color: white;
            margin-left: 20px;
            padding: 0 30px;
            border: none;
        }

        .container main .add {
            background-color: rgb(44, 156, 44);
            border-radius: 5px;
            text-align: center;
            line-height: 40px;
            color: white;
            padding: 0 30px;
            border: none;
        }

        .container main table {
            margin: 20px 0;
            width: 100%;
            line-height: 40px;
            text-align: center;
        }

        .container main table tr th {
            max-width: 200px;
        }

        .container main table tr th:first-child,
        .container main table tr td:first-child {
            text-align: left;
        }

        .container main .foot {
            text-align: center;
            line-height: 40px;
        }

        .container main .foot span {
            border: 1px solid #ccc;
            padding: 0 30px;
            display: inline-block;
        }
    </style>
</head>

<body>
    <header>
        <span class="logo">9466云专题</span>
        <span>龙猫(9466云专题)</span>
    </header>
    <section class="container">
        <aside>
            <div>首页</div>
            <div>专题</div>
            <div class="active">用户</div>
            <div>设置</div>
            <div>日志</div>
        </aside>
        <main>
            <div class="inputbox">
                <input type="text" placeholder="搜索用户"><button>搜索</button>
            </div>
            <button class="add">+ 添加用户</button>
            <table>
                <thead>
                    <tr>
                        <th>邮箱(用户)</th>
                        <th>姓名</th>
                        <th>电话</th>
                        <th>所属组</th>
                        <th>管理员</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>123123123@qq.com</td>
                        <td>李彦慧</td>
                        <td>13611129070</td>
                        <td>编辑组</td>
                        <td>是</td>
                        <td> <span class="statusok">正常</span> </td>
                        <td> <span>编辑</span> <span>删除</span> </td>
                    </tr>
                    <tr>
                        <td>123123123@qq.com</td>
                        <td>李彦慧</td>
                        <td>13611129070</td>
                        <td>编辑组</td>
                        <td>是</td>
                        <td> <span class="statusok">正常</span> </td>
                        <td> <span>编辑</span> <span>删除</span> </td>
                    </tr>
                    <tr>
                        <td>123123123@qq.com</td>
                        <td>李彦慧</td>
                        <td>13611129070</td>
                        <td>编辑组</td>
                        <td>是</td>
                        <td> <span class="statusok">正常</span> </td>
                        <td> <span>编辑</span> <span>删除</span> </td>
                    </tr>
                </tbody>
            </table>
            <div class="foot">
                <span>上一页</span>
                <span>下一页</span>
            </div>
        </main>
    </section>
    <script src="./promise-ajax.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/Mock.js/1.0.0/mock.js"></script>
    <script src="./mockdata.js"></script>
</body>

</html>
<script>
    //任务列表：
    //1.分页
    //2.添加用户
    //3.按关键词搜索用户
    //4.删除用户
    //5.编辑
    //6.登录(其他页面)
    //7.注册(其他页面)

    //表格中渲染的数据来自于服务器(服务器是提供服务/数据的的一方)
    //只要向服务器发起ajax请求，就可以获取到来自服务器的数据


    //请求json数据, 渲染数据到页面中
    // ajax('get','./tabledata.json',{}).then((res)=>{
    //     render( res )
    // })
    render(data.list)

    //渲染表格数据
    function render(data) {
        var str = data.map((item, index) => {
            return `
                <tr>
                    <td>${item.email}</td>
                    <td>${item.name}</td>
                    <td>${item.phone}</td>
                    <td>${item.ingroup}</td>
                    <td>${item.isadmin ? '是' : '否'}</td>
                    <td> <span class="statusok">${item.status ? '正常' : '异常'}</span> </td>
                    <td> <span>编辑</span> <span>删除</span> </td>
                </tr>
            `
        }).join('')
        document.querySelector('tbody').innerHTML = str
    }
</script>